package com.yorge.controller;

import com.yorge.client.PaymentClient;
import com.yorge.entities.CommonResult;
import com.yorge.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@RestController
@Slf4j
@RequestMapping("/order")
public class OrderController {

    @Resource
    private PaymentClient paymentClient;

    @RequestMapping("/getPayment/{id}")
    public CommonResult<Payment> getPayment(@PathVariable Long id) {
        return paymentClient.getPayment(id);
    }

    @RequestMapping("/addPayment")
    public CommonResult<String> addPayment(Payment payment) {
        return paymentClient.addPayment(payment);
    }


    @GetMapping("/timeOut")
    public String timeOut() throws InterruptedException {
        return paymentClient.timeOut();
    }
}
